package com.itestor.iptv.global.utils;

import javax.servlet.http.HttpServletRequest;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.lang.StringUtils;

import com.itestor.iptv.global.GlobalConstant;


public class FramePageInterceptor implements MethodInterceptor {

	private static final String RP_URL_DEFAULT = "f";

	private String requestParameterUrl = RP_URL_DEFAULT;

	/**
	 * @param invocation 参数
	 * @return object
	 * @throws Throwable any exception
	 **/
	public Object invoke(MethodInvocation invocation) throws Throwable {
		HttpServletRequest request = (HttpServletRequest) invocation.getArguments()[2];

		String url = request.getParameter(requestParameterUrl);
		if (!StringUtils.isEmpty(url)) {
			request.setAttribute(GlobalConstant.REQUEST_ATTR_FRAME_URL, url);
		}
		return invocation.proceed();
	}
}
